#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int n = 0, m = 0;
    scanf("%d %d", &n, &m);
    int arr1[1000] = { 0 };
    int arr2[1000] = { 0 };
    int arr3[2000] = { 0 };
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr1[i]);
    }
    for (int i = 0; i < m; i++) {
        scanf("%d", &arr2[i]);
    }
    int i = 0, j = 0;
    int num = 0;
    while (1) {
        if (i >= n) {
            arr3[num] = arr2[j];
            j++;
        }
        else if (j >= m) {
            arr3[num] = arr1[i];
            i++;
        }
        else {
            if (arr1[i] <= arr2[j]) {
                arr3[num] = arr1[i];
                i++;
            }
            else {
                arr3[num] = arr2[j];
                j++;
            }
        }
        num++;
        if (num == n + m)
            break;
    }
    for (int i = 0; i < n + m; i++) {
        printf("%d ", arr3[i]);
    }


    return 0;
}